import { View } from "@tarojs/components";
import { isString } from "@tarojs/shared";
import { ReactNode } from "react";

type ByColProps = {
  span?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | "none" | "auto";
  className?: string;
  children?: ReactNode;

  onClick?: () => void;
};
export default ({
  span = "auto",
  className,
  children,
  onClick,
}: ByColProps) => {
  const style = isString(span)
    ? { flex: span }
    : { width: (100 / 12) * span + "%" };

  return (
    <View className={className} style={style} onClick={onClick}>
      {children}
    </View>
  );
};
